﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Db4objects.Db4o.Linq;
using DocManagerORM.ORM;
using DocManagerORM.Utils;

namespace DocManagerORM.DB4O
{
    public class QueryCodifiche : DB4OBase
    {

        public static void LoadCacheCategorie()
        {
                        
        }//fM


        public  IQueryable<Categorie> getCATEGORIE(int? pID)
        {
           if (pID == null)
               return Database.AsQueryable<Categorie>().OrderBy(x => x.Categoria);
            else
                return Database.AsQueryable<Categorie>().Where(x=> x.ID == pID.Value).OrderBy(x=> x.Categoria)   ;       
        }

        public IQueryable<SottoCategorie> getSottoCATEGORIE(int? pIDPadre)
        {
            if (pIDPadre == null)
                return Database.AsQueryable <SottoCategorie>().OrderBy(s => s.Categoria);
            else
                return Database.AsQueryable<SottoCategorie>().Where(c => c.Fk_IDCat == pIDPadre.Value)
                    .OrderBy(s=> s.Categoria);
        }

        public BindingListExt<Categorie> getCATEGORIEbl(int? pID)
        {
            var listRet = Database.AsQueryable <Categorie>().Where(c => c.ID == pID.Value).ToList();
            BindingListExt<Categorie> bl = null;
            //bl = new BindingListExt<Categorie>(listRet,);//<< settare database
             return bl;
        }


        public BindingListExt<SottoCategorie> getSottoCATEGORIEbl(int pIDpadre)
        {
            var listRet = Database.AsQueryable<SottoCategorie>().Where(c => c.Fk_IDCat == pIDpadre).ToList();
            BindingListExt<SottoCategorie> bl = null;
            //bl = new BindingListExt<SottoCategorie>(listRet, ref m_Entity);
            return bl;
        }


        public IQueryable<AttivitaIter> getAttivitaIter(int pTipo)
        {
            var listRet = Database.AsQueryable <AttivitaIter>().Where(x => x.Tipo == pTipo);
            return listRet;
        }
        
          
    }//fC
}
